
# LOAD PACKAGES

library(foreign)
library(xtable)
library(Hmisc)
library(lattice)
library(car)
library(sandwich)
library(lmtest)
library(zoo)
library(Matching)
library(plm)
library(plyr)
library(AER)
library(mlogit)
library(lattice)
library(texreg)
library(RColorBrewer)


# SET WORKING DIRECTORY 

setwd ("")

# LOAD FUNCTIONS THAT WILL BE USED LATER FOR PLOTS AND CLUSTERED SEs
source("functions.R")

# LOAD OBSERVATIONAL DATA 
dobs<-read.dta("obsanalysis.dta")

# LOAD CONJOINT DATA
d<-read.dta("conjoint_analysis.dta")
	
	
############## CONTENTS #################################

# TABLE 2 MAIN RESULTS - WARTIME VIOLENCE AND HOSTING OF REFUGEES
# TABLE 3: WARTIME VIOLENCE AND PREFERENCE SHIFTS
# ANALYSIS OF DATA FROM CONJOINT EXPERIMENT
	# AVERAGE EFFECTS IN PRIME CONTROL GROUP (FOR FIGURE 2)
	# MARGINAL EFFECTS BY PAST WAR EXPERIENCE (FOR FIGURE 2)
	# RESULTS WITH AND WITHOUT PRIME (FOR FIGURE 3)
	# RESULTS IN TABLE FORM (APPENDIX 5)
	# PLOT FIGURE 2 - AVERAGE EFFECTS AND MARGINAL EFFECTS BY WARTIME VIOLENCE
	# PLOT FIGURE 3 - MARGINAL EFFECTS BY EMPATHETIC PRIME
	
# APPENDIX ############################	
# APPENDIX 3 SELECTION INTO VIOLENCE AND SENSITIVITY ANALYSIS ##############
	# APPENDIX 3.2 SELECTION INTO VIOLENCE ##############
	# APPENDIX 3.2 CORRELATES OF HOSTING FIGURE ###########
	# APPENDIX 3.3 OSTER SENSITIVITY ANALYSIS ##############
# APPENDIX 4: SUPPLEMENTAL ANALYSES
	# APPENDIX 4.1: REPLICATE TABLE 2 MAIN RESULTS AFTER CONDITIONING ON PROSOCIALITY
	# APPENDIX 4.1: REPLICATE TABLE 3 MAIN RESULTS AFTER CONDITIONING ON PROSOCIALITY
	# APPENDIX 4.2: SOCIAL NORMS AND HOSTING
	# APPENDIX 4.3: SELECTIVE MIGRATION
	# APPENDIX 4.3: REPLICATION OF TABLE 2 IN MAIN PAPER, SUB-SETTING TO THOSE BORN IN TOWN
	# APPENDIX 4.3: REPLICATION OF TABLE 3 IN MAIN PAPER, SUB-SETTING TO THOSE BORN IN TOWN
	# APPENDIX 4.4 NON-ASSOCIATION OF VIOLENCE AND RECIPROCITY 
# MISCELLANEOUS TESTS


	
###########################################################################
# TABLE 2 MAIN RESULTS - WAR TIME VIOLENCE AND HOSTING OF REFUGEES ########
###########################################################################


	ctrls<-c("age1830","age3140","age4150","age5160","age61","female","readnews_dum","low_income_personal","high_wealth","vote2011_dum","up_partisan_2011")
	
	
	h1<-lm(nummonths_host~ warvict+factor(towncode), data=dobs)
	h1_se<-coeftest(h1, vcov = vcovCluster(h1, cluster = dobs[as.numeric(rownames(model.matrix(h1))),]$towncode))	
	h1c<-lm(paste("nummonths_host ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h1c_se<-coeftest(h1c, vcov = vcovCluster(h1c, cluster = dobs[as.numeric(rownames(model.matrix(h1c))),]$towncode))
		
	h2<-lm(host_EthnicOutgroup_dum~ warvict+factor(towncode), data=dobs)
	h2_se<-coeftest(h2, vcov = vcovCluster(h2, cluster = dobs[as.numeric(rownames(model.matrix(h2))),]$towncode))	
	h2c<-lm(paste("host_EthnicOutgroup_dum ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h2c_se<-coeftest(h2c, vcov = vcovCluster(h2c, cluster = dobs[as.numeric(rownames(model.matrix(h2c))),]$towncode))
			
	h3<-lm(host_Muslim_dum~ warvict+factor(towncode), data=dobs)
	h3_se<-coeftest(h3, vcov = vcovCluster(h3, cluster = dobs[as.numeric(rownames(model.matrix(h3))),]$towncode))	
	h3c<-lm(paste("host_Muslim_dum ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h3c_se<-coeftest(h3c, vcov = vcovCluster(h3c, cluster = dobs[as.numeric(rownames(model.matrix(h3c))),]$towncode))
	
	h4<-lm(refhealth_dum~ warvict+factor(towncode), data=dobs)
	h4_se<-coeftest(h4, vcov = vcovCluster(h4, cluster = dobs[as.numeric(rownames(model.matrix(h4))),]$towncode))
	h4c<-lm(paste("refhealth_dum ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h4c_se<-coeftest(h4c, vcov = vcovCluster(h4c, cluster = dobs[as.numeric(rownames(model.matrix(h4c))),]$towncode))
	
	h5<-lm(reffoodsec_dum~ warvict+factor(towncode), data=dobs)
	h5_se<-coeftest(h5, vcov = vcovCluster(h5, cluster = dobs[as.numeric(rownames(model.matrix(h5))),]$towncode))
	h5c<-lm(paste("reffoodsec_dum ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h5c_se<-coeftest(h5c, vcov = vcovCluster(h5c, cluster = dobs[as.numeric(rownames(model.matrix(h5c))),]$towncode))
	
	h6<-lm(refviolconf_dum~ warvict+factor(towncode), data=dobs)
	h6_se<-coeftest(h6, vcov = vcovCluster(h6, cluster = dobs[as.numeric(rownames(model.matrix(h6))),]$towncode))
	h6c<-lm(paste("refviolconf_dum ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h6c_se<-coeftest(h6c, vcov = vcovCluster(h6c, cluster = dobs[as.numeric(rownames(model.matrix(h6c))),]$towncode))
		
	
	omit<-"(towncode)|(Intercept)|(hh)|(Mus)|(gio)|(grebo)|(krahn) |(mano)|(male)|(age)|(edu)|(krahn)|(chief)"
	modelnames1<-c("# Refugee Months Host","# Refugee Months Host","# Refugee Months Host (Ethnic Outgroup)","# Refugee Months Host (Ethnic Outgroup)"," # Refugee Months Host (Religious Outgroup)","# Refugee Months Host (Religious Outgroup)")
	modelnames2<-c("Hosted family w/ Health Problems at arrival","Hosted family w/ Health Problems at arrival","Hosted family w/ Food Insecure at arrival","Hosted family Food Insecure at arrival","Hosted family Fleeing Direct Violence","Hosted family Fleeing Direct Violence")
		
	screenreg(list(h1, h1c, h2, h2c, h3, h3c),override.se=list(h1_se[,2], h1c_se[,2],h2_se[,2], h2c_se[,2],h3_se[,2], h3c_se[,2]), override.pval=list(h1_se[,4], h1c_se[,4],h2_se[,4], h2c_se[,4],h3_se[,4], h3c_se[,4]),digits=2, stars=c(0.01, 0.05, 0.1),sideways=T, omit.coef=omit,custom.model.names=modelnames1, bold=.1,scriptsize=TRUE)

	screenreg(list(h4, h4c, h5, h5c, h6, h6c),override.se=list(h4_se[,2], h4c_se[,2],h5_se[,2], h5c_se[,2],h6_se[,2], h6c_se[,2]), override.pval=list(h4_se[,4], h4c_se[,4],h5_se[,4], h5c_se[,4],h6_se[,4], h6c_se[,4]),digits=2, omit.coef=omit,stars=c(0.01, 0.05, 0.1),custom.model.names=modelnames2,sideways=T, bold=.1,scriptsize=TRUE)

	
		
########################################################
# TABLE 3: WARTIME VIOLENCE AND PREFERENCE SHIFTS ######
########################################################

	#per_nummonths_host_Muslim per_nummonths_host_noncoeth

	h2<-lm(per_nummonths_host_noncoeth~ warvict+factor(towncode), data=dobs)
	h2_se<-coeftest(h2, vcov = vcovCluster(h2, cluster = dobs[as.numeric(rownames(model.matrix(h2))),]$towncode))
	h2c<-lm(paste("per_nummonths_host_noncoeth ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h2c_se<-coeftest(h2c, vcov = vcovCluster(h2c, cluster = dobs[as.numeric(rownames(model.matrix(h2c))),]$towncode))
	
	h3<-lm(per_nummonths_host_Muslim~ warvict+factor(towncode), data=dobs)
	h3_se<-coeftest(h3, vcov = vcovCluster(h3, cluster = dobs[as.numeric(rownames(model.matrix(h3))),]$towncode))
	h3c<-lm(paste("per_nummonths_host_Muslim ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h3c_se<-coeftest(h3c, vcov = vcovCluster(h3c, cluster = dobs[as.numeric(rownames(model.matrix(h3c))),]$towncode))
	
	h4<-lm(avg_refhealth~ warvict+factor(towncode), data=dobs)
	h4_se<-coeftest(h4, vcov = vcovCluster(h4, cluster = dobs[as.numeric(rownames(model.matrix(h4))),]$towncode))
	h4c<-lm(paste("avg_refhealth ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h4c_se<-coeftest(h4c, vcov = vcovCluster(h4c, cluster = dobs[as.numeric(rownames(model.matrix(h4c))),]$towncode))
	
	h5<-lm(avg_reffoodsec~ warvict+factor(towncode), data=dobs)
	h5_se<-coeftest(h5, vcov = vcovCluster(h5, cluster = dobs[as.numeric(rownames(model.matrix(h5))),]$towncode))
	h5c<-lm(paste("avg_reffoodsec ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h5c_se<-coeftest(h5c, vcov = vcovCluster(h5c, cluster = dobs[as.numeric(rownames(model.matrix(h5c))),]$towncode))
	
	h6<-lm(avg_refviolconf~ warvict+factor(towncode), data=dobs)
	h6_se<-coeftest(h6, vcov = vcovCluster(h6, cluster = dobs[as.numeric(rownames(model.matrix(h6))),]$towncode))
	h6c<-lm(paste("avg_refviolconf ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h6c_se<-coeftest(h6c, vcov = vcovCluster(h6c, cluster = dobs[as.numeric(rownames(model.matrix(h6c))),]$towncode))
	
	
	omit<-"(towncode)|(Intercept)|(hh)|(Mus)|(gio)|(grebo)|(krahn) |(mano)|(male)|(age)|(edu)|(krahn)|(chief)"

	modelnames2<-c("% of refugee months (non coethnic refugees)","% of refugee months (non coethnic refugees)","% of refugee months (Muslim refugees)","% of refugee months (Muslim refugees)","% Refugee Families w/ Health Problems at arrival","% Refugee Families w/ Health Problems at arrival","% Refugee Families Food Insecure at arrival","% Refugee Families Food Insecure at arrival","% Refugee Families Fleeing Direct Violence","% Refugee Families Fleeing Direct Violence")		
	
	screenreg(list(h2,h2c,h3,h3c,h4, h4c, h5, h5c, h6, h6c),override.se=list(h2_se[,2], h2c_se[,2],h3_se[,2], h3c_se[,2],h4_se[,2], h4c_se[,2],h5_se[,2], h5c_se[,2],h6_se[,2], h6c_se[,2]), override.pval=list(h2_se[,4], h2c_se[,4],h3_se[,4], h3c_se[,4],h4_se[,4], h4c_se[,4],h5_se[,4], h5c_se[,4],h6_se[,4], h6c_se[,4]),digits=2, omit.coef=omit,stars=c(0.01, 0.05, 0.1),custom.model.names=modelnames2,sideways=T, bold=.1)
	
	screenreg(list(h4, h4c, h5, h5c, h6, h6c),override.se=list(h4_se[,2], h4c_se[,2],h5_se[,2], h5c_se[,2],h6_se[,2], h6c_se[,2]), override.pval=list(h4_se[,4], h4c_se[,4],h5_se[,4], h5c_se[,4],h6_se[,4], h6c_se[,4]),digits=2, omit.coef=omit,stars=c(0.01, 0.05, 0.1),custom.model.names=modelnames2,sideways=T, bold=.1)
	

  

#########################################################
############### ANALYSIS OF CONJOINT DATA ###############
#########################################################

# AVERAGE EFFECTS IN PRIME CONTROL GROUP (FOR FIGURE 2)

	m1_cnj<-lm(decision~woman_hh + farmer + hunger +coreligious+coethnic,data=d[d$weprime==0,])
	# cluster SEs
	m1_cnj_se<-robust.se(m1_cnj,d[rownames(m1_cnj$model),"respid"])[[2]]	
	# cluster vcov
	m1_cnj_vcov<-robust.se(m1_cnj,d[rownames(m1_cnj$model),"respid"])[[1]]	
	
# MARGINAL EFFECTS BY PAST WAR EXPERIENCE (FOR FIGURE 2)
	
	m2_cnj<-lm(decision~woman_hh + farmer + hunger +coreligious+coethnic+warvict:(woman_hh + farmer + hunger +coreligious+coethnic),data=d[d$weprime==0,])	
	# cluster SEs
	m2_cnj_se<-robust.se(m2_cnj,d[rownames(m2_cnj$model),"respid"])[[2]]	
	m2_cnj_se
	# cluster vcov
	m2_cnj_vcov<-robust.se(m2_cnj,d[rownames(m2_cnj$model),"respid"])[[1]]	
	
# RESULTS WITH AND WITHOUT PRIME (FOR FIGURE 3)
	
m3_cnj<-lm(decision~woman_hh + farmer + hunger +coreligious+coethnic+weprime:(woman_hh + farmer + hunger +coreligious+coethnic),data=d)
	# cluster SEs
	m3_cnj_se<-robust.se(m3_cnj,d[rownames(m3_cnj$model),"respid"])[[2]]	
	# cluster vcov
	m3_cnj_vcov<-robust.se(m3_cnj,d[rownames(m3_cnj$model),"respid"])[[1]]	
	
	
# RESULTS IN TABLE FORM (FOR APPENDIX 5)

	omit<-"(county)|(Intercept)"
	modelnames1<-c("Hosted","Hosted","Hosted")
	
	screenreg(list(m1_cnj, m2_cnj,m3_cnj),override.se=list(m1_cnj_se[,2], m2_cnj_se[,2], m2_cnj_se[,2]), override.pval=list(m1_cnj_se[,4], m2_cnj_se[,4], m3_cnj_se[,4]),digits=2, stars=c(0.01, 0.05, 0.1),sideways=T, omit.coef=omit,custom.model.names=modelnames1, bold=.1,scriptsize=TRUE)
	
	set1<-texreg(list(m1_cnj, m2_cnj,m3_cnj),override.se=list(m1_cnj_se[,2], m2_cnj_se[,2], m2_cnj_se[,2]), override.pval=list(m1_cnj_se[,4], m2_cnj_se[,4], m3_cnj_se[,4]),digits=2, stars=c(0.01, 0.05, 0.1),sideways=T, omit.coef=omit,custom.model.names=modelnames1, bold=.1,scriptsize=TRUE)
	

###############################################################################################
# PLOT FIGURE 1 - AVERAGE EFFECTS AND MARGINAL EFFECTS BY WARTIME VIOLENCE ####################
###############################################################################################

# RETURN MARGINAL EFFECT 

	me_coreligious<-return_interaction_continuous(m2_cnj, effect="coreligious", moderator="warvict", interaction="coreligious:warvict", varcov=m2_cnj_vcov)
	me_coethnic<-return_interaction_continuous(m2_cnj, effect="coethnic", moderator="warvict", interaction="coethnic:warvict",varcov=m2_cnj_vcov)
	me_woman_hh<-return_interaction_continuous(m2_cnj, effect="woman_hh", moderator="warvict", interaction="woman_hh:warvict",varcov=m2_cnj_vcov)
	me_farmer<-return_interaction_continuous(m2_cnj, effect="farmer", moderator="warvict", interaction="farmer:warvict",varcov=m2_cnj_vcov)
	me_hunger<-return_interaction_continuous(m2_cnj, effect="hunger", moderator="warvict", interaction="hunger:warvict",varcov=m2_cnj_vcov)	
	
pdf(file="figure1.pdf")
par(mfrow=c(2,3), mar=c(5,4.5,1,1))

	# PLOT AVERAGE EFFECTS AMONG THOSE NOT PRIMED
	
	plot(1,type="n",xlim=c(-.02,.22),ylim=c(.1,.9),cex.sub=.75, xlab="",ylab="",xaxt="n",yaxt="n",cex.lab=1.25,main="",cex.main=1.25,font.main=1, tck=.1)
	abline(v=0,lty=2)
	
	
	rnn <- c("Female HH","Farmer","Hunger","Coreligious","Coethnic")
	of<-m1_cnj_se
	
	for(i in 2:6) {		
	  
	  lines(x=c(of[i,1]-1.96*of[i,2],of[i,1]+1.96*of[i,2]),y=c((i-1)/6,(i-1)/6), col="darkgrey", lwd=2)
	  points(x=of[i,1],y=(i-1)/6, pch=16,cex=2)  
	  
	  # ADD SOME TEXT
	  text(rnn[i-1],x=of[i,1],y=(i-1)/6+.05,cex=1.5)
	  
	  #k <- k+.1
	}
	
	axis(1,labels=c(".05",".1",".15",".20"),at=c(.05,.1,.15,.2), las=TRUE, tick=FALSE, tck=.1, pos=.08, cex.axis = 1.5)
	axis(1,labels=c("Change in Pr(Prefer to host refugee)"),at=c(.1), las=TRUE, tick=FALSE, pos=0, cex.axis = 1.5)
	
	
	# PLOT MARGINAL EFFECTS BY PRIOR VIOLENCE EXPOSURE AMONG THOSE NOT PRIMED


plot(x=c(), y=c(), ylim=c(mean(me_woman_hh$delta_1)-.15,mean(me_woman_hh$delta_1)+.15), xlim=c(-.5, 6.5), xlab="Past Violence",cex.lab=1.5, ylab="Marginal Effect of Female HH")
  abline(h=0, lty=2,lwd=2)
	lines(y=me_woman_hh$delta_1, x=me_woman_hh$x_2,lwd=2)
		lines(y=me_woman_hh$lower_bound, x=me_woman_hh$x_2, lty=2,lwd=1)
		lines(y=me_woman_hh$upper_bound, x=me_woman_hh$x_2, lty=2,lwd=1)
    par(new=T)
    hist(d$warvict, axes=F, xlab="", ylab="",main="",border="grey",breaks=c(-.5,.5,1.5,2.5,3.5,4.5,5.5,6.5))

plot(x=c(), y=c(), ylim=c(mean(me_farmer$delta_1)-.15,mean(me_farmer$delta_1)+.15), xlim=c(-.5, 6.5), xlab="Past Violence",cex.lab=1.5, ylab="Marginal Effect of Farmer")
  abline(h=0, lty=2,lwd=2)
	lines(y=me_farmer$delta_1, x=me_farmer$x_2,lwd=2)
		lines(y=me_farmer$lower_bound, x=me_farmer$x_2, lty=2,lwd=1)
		lines(y=me_farmer$upper_bound, x=me_farmer$x_2, lty=2,lwd=1)
    par(new=T)
    hist(d$warvict, axes=F, xlab="", ylab="",main="",border="grey",breaks=c(-.5,.5,1.5,2.5,3.5,4.5,5.5,6.5))

plot(x=c(), y=c(), ylim=c(mean(me_hunger$delta_1)-.15,mean(me_hunger$delta_1)+.15), xlim=c(-.5, 6.5), xlab="Past Violence",cex.lab=1.5, ylab="Marginal Effect of Hunger")
  abline(h=0, lty=2,lwd=2)
		lines(y=me_hunger$delta_1, x=me_hunger$x_2,lwd=2)
		lines(y=me_hunger$lower_bound, x=me_hunger$x_2, lty=2,lwd=1)
		lines(y=me_hunger$upper_bound, x=me_hunger$x_2, lty=2,lwd=1)
    par(new=T)
    hist(d$warvict, axes=F, xlab="", ylab="",main="",border="grey",breaks=c(-.5,.5,1.5,2.5,3.5,4.5,5.5,6.5))
	
plot(x=c(), y=c(), ylim=c(mean(me_coreligious$delta_1)-.15,mean(me_coreligious$delta_1)+.15), xlim=c(-.5, 6.5), xlab="Past Violence",cex.lab=1.5, ylab="Marginal Effect of Coreligious")
  abline(h=0, lty=2,lwd=2)
		lines(y=me_coreligious$delta_1, x=me_coreligious$x_2,lwd=2)
		lines(y=me_coreligious$lower_bound, x=me_coreligious$x_2, lty=2,lwd=1)
		lines(y=me_coreligious$upper_bound, x=me_coreligious$x_2, lty=2,lwd=1)
    par(new=T)
hist(d$warvict, axes=F, xlab="", ylab="",main="",border="grey",breaks=c(-.5,.5,1.5,2.5,3.5,4.5,5.5,6.5))

plot(x=c(), y=c(), ylim=c(mean(me_coethnic$delta_1)-.15,mean(me_coethnic$delta_1)+.15), xlim=c(-.5, 6.5), xlab="Past Violence",cex.lab=1.5, ylab="Marginal Effect of  Coethnic")
  abline(h=0, lty=2,lwd=2)
		lines(y=me_coethnic$delta_1, x=me_coethnic$x_2,lwd=2)
		lines(y=me_coethnic$lower_bound, x=me_coethnic$x_2, lty=2,lwd=1)
		lines(y=me_coethnic$upper_bound, x=me_coethnic$x_2, lty=2,lwd=1)
    par(new=T)
    hist(d$warvict, axes=F, xlab="", ylab="",main="",border="grey",breaks=c(-.5,.5,1.5,2.5,3.5,4.5,5.5,6.5))
	
dev.off()	



###########################################################################
# PLOT FIGURE 2 -  MARGINAL EFFECTS BY EMPATHETIC PRIME ###################
###########################################################################

	
	# output matrix
		out<-matrix(NA,nrow=10,ncol=2)
		colnames(out)<-c("coef","se")
		rownames(out)<-c(rownames(m3_cnj_se)[2:6],paste(rownames(m3_cnj_se)[2:6],"+",rownames(m3_cnj_se)[7:11]))
		out
		
		out[1:5,]<-m3_cnj_se[2:6,1:2]
		out[6,]<-return_interaction_binary(m3_cnj, effect="woman_hh", moderator="weprime", interaction="woman_hh:weprime", varcov = m1_cnj_vcov)
		out[7,]<-return_interaction_binary(m3_cnj, effect="farmer", moderator="weprime", interaction="farmer:weprime", varcov = m1_cnj_vcov)
		out[8,]<-return_interaction_binary(m3_cnj, effect="hunger", moderator="weprime", interaction="hunger:weprime", varcov = m1_cnj_vcov)
		out[9,]<-return_interaction_binary(m3_cnj, effect="coreligious", moderator="weprime", interaction="coreligious:weprime", varcov = m1_cnj_vcov)
		out[10,]<-return_interaction_binary(m3_cnj, effect="coethnic", moderator="weprime", interaction="coethnic:weprime", varcov = m1_cnj_vcov)
	
pdf(file="figure2.pdf")

par(mar=c(4.5,2,1,2))
	
	txt3<- "Change in Pr(Prefer to Host Refugee)" 
	#color<-brewer.pal(4,"Set1")
	color<-brewer.pal(9,"Greys")
	rownamez<-c("Female","Farmer","Hunger","Coreligious","Coethnic")
	
	plot(1,type="n",xlim=c(-.02,.25),ylim=c(.5,5), cex.sub=.75, xlab=txt3,ylab="",yaxt="n",cex.lab=1.5,cex.main=1.25,tck=-.05)
	abline(v=0,col="grey")

	for(i in 1:5) {		
	  
	text(rownamez[i],x=((out[i,1]+out[i+5,1])/2), y=i,cex=1.5)
	  
	  lines(x=c(out[i+5,1]-1.96*out[i+5,2],out[i+5,1]+1.96*out[i+5,2]),y=c(i-.2,i-.2), col="darkgray", lwd=1)
	  points(x=out[i+5,1],y=i-.2, pch=17, col=color[9], cex=2)  

	  lines(x=c(out[i,1]-1.96*out[i,2],out[i,1]+1.96*out[i,2]),y=c(i-.4,i-.4), col="darkgray", lwd=1)
	  points(x=out[i,1],y=i-.4, pch=15, col=color[9], cex=2)  
	  
	
	}

	legend("topright", c("Empathetic prime","No empathetic prime"),pch=c(17,15), cex=1.25,bty="n", col=c(color[9],color[9]), pt.cex=2) # fill=color[2:1],

dev.off()

	
	
#########################################
### APPENDIX ############################	
#########################################


######################################################
# APPENDIX 3.1 SELECTION INTO VIOLENCE ##############
######################################################

	
	selection<-lm(warvict~ age2 + age3 + age4 + age5 + chiefrelbfrwar + fatheredu + motheredu  +hhlivestockbfrwar  +hhprewar_formal  +hhprewar_business + Muslim + gio + grebo + krahn + mano +male+bornintown+factor(towncode),data=dobs)
	
		selection_se<-coeftest(selection, vcov = vcovCluster(selection, cluster = dobs[as.numeric(rownames(model.matrix(selection))),]$towncode))
		
		coefnames<-c("Intercept","Age 25-35","Age 36-45","Age 46-55","Age 55+","Related to chief (prewar)","Father edu","Mother edu","HH owned livestock (prewar)","HH had formal job (prewar)","HH had business (prewar)","Muslim","Gio Ethnicity","Grebo Ethnicity","Krahn Ethnicity","Mano Ethnicity","Male","Born in town", rep(NA,dim(selection_se)[1]-18))

		screenreg(selection,override.se=selection_se[,2], override.pval=selection_se[,4],digits=2, stars=c(0.01, 0.05, 0.1),sideways=T, omit.coef="towncode", custom.coef.names=coefnames,custom.model.names="Exposure to Violence", bold=.1,scriptsize=TRUE)		
		
		texreg(selection,override.se=selection_se[,2], override.pval=selection_se[,4],digits=2, stars=c(0.01, 0.05, 0.1),sideways=F, omit.coef="towncode",custom.model.names="Exposure to Violence",custom.coef.names=coefnames, bold=.1,scriptsize=TRUE)	



#####################################################
# APPENDIX 3.2 CORRELATES OF HOSTING FIGURE ###########
#####################################################


	dobs$highwealth<-ifelse(dobs$wealthindex>quantile(dobs$wealthindex,.5),1,0)
	dobs$highincome<-ifelse(dobs$hhearnings7d_gen>quantile(na.omit(dobs$hhearnings7d_gen),.5),1,0)
	dobs$highfarm_size_to_labor<-ifelse(dobs$farm_size_to_labor>quantile(na.omit(dobs$farm_size_to_labor),.5),1,0)
	
	
	host2<-lm(nummonths_host~ warvict_high+ lrefugee + highfarm_size_to_labor+highwealth+married_dum  + chiefrel  + readpaper + groupmember + contsick + age2 + age3 + age4 + age5 +male+factor(towncode), data=dobs)
		host2_se<-coeftest(host2, vcov = vcovCluster(host2, cluster = dobs[as.numeric(rownames(model.matrix(host2))),]$towncode))

pdf(file="correlatesofhosting.pdf")
		
par(mar=c(4,1,1,1))

	# snummonths_host
	rnn <- c("HighWarVict","PreviouslyRefugee","HighFarmLaborRatio","HighWealth","Married","ChiefRelated", "Literate","Group Member","Charitable","Age 25-35", "Age 36-45", "Age 46-55", "Age 55+", "Male")
	
	k <- 1
	j <- 1.15
	txt1 <- "Number of Refugee Months Hosted"
	txt2 <- "Change in Number Refugee Months Hosted (std)"
	txt3<- "Effect Size (months)"

	# Note: out is a matrix of regression output, where column 5 is the lower CI, column 6 the upper CI, column for the ATE, all expressed as a % of the control group mean
	n<-14
	plot(1,type="n",xlim=c(-25,25),ylim=c(1,3),cex.sub=.75, xlab="",ylab="",yaxt="n",cex.lab=1.25)
	abline(v=0,col="grey")
	title(main=txt1)	
	minor.tick(nx=2, ny=0 ,tick.ratio=.75)

	for(i in 2:15) {		
	  lines(x=c(host2_se[i,1]-1.96*host2_se[i,2],host2_se[i,1]+1.96*host2_se[i,2]),y=c(k,k), col="darkgrey", lwd=2)
	  points(x=host2_se[i,1],y=k, pch=15, col="black")  
	  text(rnn[i-1],x=host2_se[i,1],y=k+.05,cex=.9)
	  
	  j <- j+.25
	  k <- k+.15
	}
mtext(txt3, side = 1.1, line = 2, cex=1.25)

dev.off()
		
		
########################################################
# APPENDIX 3.3: OSTER SENSITIVITY ANALYSIS ##############
########################################################
		
		
# SEE STATA REPLICATION FILE		


########################################################
### APPENDIX 4: SUPPLEMENTAL ANALYSES
########################################################
	
########################################################
### APPENDIX 4.1: REPLICATE TABLE 2 MAIN RESULTS AFTER CONDITIONING ON PROSOCIALITY
########################################################

	dobs$prosociality<-(dobs$contsick/mean(dobs$contsick,na.rm=T)+dobs$groups/mean(dobs$groups,na.rm=T)+dobs$contcomm/mean(dobs$contcomm,na.rm=T))/3
	
	h1<-lm(nummonths_host~ warvict+prosociality+factor(towncode), data=dobs)
	h1_se<-coeftest(h1, vcov = vcovCluster(h1, cluster = dobs[as.numeric(rownames(model.matrix(h1))),]$towncode))	
	h1c<-lm(paste("nummonths_host ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h1c_se<-coeftest(h1c, vcov = vcovCluster(h1c, cluster = dobs[as.numeric(rownames(model.matrix(h1c))),]$towncode))
		
	h2<-lm(host_EthnicOutgroup_dum~ warvict+prosociality+factor(towncode), data=dobs)
	h2_se<-coeftest(h2, vcov = vcovCluster(h2, cluster = dobs[as.numeric(rownames(model.matrix(h2))),]$towncode))	
	h2c<-lm(paste("host_EthnicOutgroup_dum ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h2c_se<-coeftest(h2c, vcov = vcovCluster(h2c, cluster = dobs[as.numeric(rownames(model.matrix(h2c))),]$towncode))
	
	h3<-lm(host_Muslim_dum~ warvict+prosociality+factor(towncode), data=dobs)
	h3_se<-coeftest(h3, vcov = vcovCluster(h3, cluster = dobs[as.numeric(rownames(model.matrix(h3))),]$towncode))	
	h3c<-lm(paste("host_Muslim_dum ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h3c_se<-coeftest(h3c, vcov = vcovCluster(h3c, cluster = dobs[as.numeric(rownames(model.matrix(h3c))),]$towncode))
  	
	h4<-lm(refhealth_dum~ warvict+prosociality+factor(towncode), data=dobs)
	h4_se<-coeftest(h4, vcov = vcovCluster(h4, cluster = dobs[as.numeric(rownames(model.matrix(h4))),]$towncode))
	h4c<-lm(paste("refhealth_dum ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h4c_se<-coeftest(h4c, vcov = vcovCluster(h4c, cluster = dobs[as.numeric(rownames(model.matrix(h4c))),]$towncode))
	
	h5<-lm(reffoodsec_dum~ warvict+prosociality+factor(towncode), data=dobs)
	h5_se<-coeftest(h5, vcov = vcovCluster(h5, cluster = dobs[as.numeric(rownames(model.matrix(h5))),]$towncode))
	h5c<-lm(paste("reffoodsec_dum ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h5c_se<-coeftest(h5c, vcov = vcovCluster(h5c, cluster = dobs[as.numeric(rownames(model.matrix(h5c))),]$towncode))
	
	h6<-lm(refviolconf_dum~ warvict+prosociality+factor(towncode), data=dobs)
	h6_se<-coeftest(h6, vcov = vcovCluster(h6, cluster = dobs[as.numeric(rownames(model.matrix(h6))),]$towncode))
	h6c<-lm(paste("refviolconf_dum ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h6c_se<-coeftest(h6c, vcov = vcovCluster(h6c, cluster = dobs[as.numeric(rownames(model.matrix(h6c))),]$towncode))
	
	omit<-"(towncode)|(Intercept)|(hh)|(Mus)|(gio)|(grebo)|(krahn) |(mano)|(male)|(age)|(edu)|(krahn)|(chief)"
	modelnames1<-c("# Refugee Months Host","# Refugee Months Host","# Refugee Months Host (Ethnic Outgroup)","# Refugee Months Host (Ethnic Outgroup)"," # Refugee Months Host (Religious Outgroup)","# Refugee Months Host (Religious Outgroup)")
	modelnames2<-c("# Refugee Families w/ Health Problems at arrival","# Refugee Families w/ Health Problems at arrival","# Refugee Families Food Insecure at arrival","# Refugee Families Food Insecure at arrival","# Refugee Families Fleeing Direct Violence","# Refugee Families Fleeing Direct Violence")
		
	
	screenreg(list(h1, h1c, h2, h2c, h3, h3c),override.se=list(h1_se[,2], h1c_se[,2],h2_se[,2], h2c_se[,2],h3_se[,2], h3c_se[,2]), override.pval=list(h1_se[,4], h1c_se[,4],h2_se[,4], h2c_se[,4],h3_se[,4], h3c_se[,4]),digits=2, stars=c(0.01, 0.05, 0.1),sideways=T, omit.coef=omit,custom.model.names=modelnames1, bold=.1,scriptsize=TRUE)

	screenreg(list(h4, h4c, h5, h5c, h6, h6c),override.se=list(h4_se[,2], h4c_se[,2],h5_se[,2], h5c_se[,2],h6_se[,2], h6c_se[,2]), override.pval=list(h4_se[,4], h4c_se[,4],h5_se[,4], h5c_se[,4],h6_se[,4], h6c_se[,4]),digits=2, omit.coef=omit,stars=c(0.01, 0.05, 0.1),custom.model.names=modelnames2,sideways=T, bold=.1,scriptsize=TRUE)
	
	
	set1<-texreg(list(h1, h1c, h2, h2c, h3, h3c),override.se=list(h1_se[,2], h1c_se[,2],h2_se[,2], h2c_se[,2],h3_se[,2], h3c_se[,2]), override.pval=list(h1_se[,4], h1c_se[,4],h2_se[,4], h2c_se[,4],h3_se[,4], h3c_se[,4]),digits=2, stars=c(0.01, 0.05, 0.1), omit.coef=omit,custom.model.names=modelnames1, bold=.1,scriptsize=TRUE)

	set2<-texreg(list(h4, h4c, h5, h5c, h6, h6c),override.se=list(h4_se[,2], h4c_se[,2],h5_se[,2], h5c_se[,2],h6_se[,2], h6c_se[,2]), override.pval=list(h4_se[,4], h4c_se[,4],h5_se[,4], h5c_se[,4],h6_se[,4], h6c_se[,4]),digits=2, omit.coef=omit,stars=c(0.01, 0.05, 0.1),custom.model.names=modelnames2, bold=.1,scriptsize=TRUE)

	
########################################################
### APPENDIX 4.1: REPLICATE TABLE 3 MAIN RESULTS AFTER CONDITIONING ON PROSOCIALITY
########################################################

	h2<-lm(per_nummonths_host_noncoeth~ warvict+prosociality+factor(towncode), data=dobs)
	h2_se<-coeftest(h2, vcov = vcovCluster(h2, cluster = dobs[as.numeric(rownames(model.matrix(h2))),]$towncode))
	h2c<-lm(paste("per_nummonths_host_noncoeth ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h2c_se<-coeftest(h2c, vcov = vcovCluster(h2c, cluster = dobs[as.numeric(rownames(model.matrix(h2c))),]$towncode))
	
	h3<-lm(per_nummonths_host_Muslim~ warvict+prosociality+factor(towncode), data=dobs)
	h3_se<-coeftest(h3, vcov = vcovCluster(h3, cluster = dobs[as.numeric(rownames(model.matrix(h3))),]$towncode))
	h3c<-lm(paste("per_nummonths_host_Muslim ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h3c_se<-coeftest(h3c, vcov = vcovCluster(h3c, cluster = dobs[as.numeric(rownames(model.matrix(h3c))),]$towncode))
	
	
	h4<-lm(avg_refhealth~ warvict+prosociality+factor(towncode), data=dobs)
	h4_se<-coeftest(h4, vcov = vcovCluster(h4, cluster = dobs[as.numeric(rownames(model.matrix(h4))),]$towncode))
	h4c<-lm(paste("avg_refhealth ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h4c_se<-coeftest(h4c, vcov = vcovCluster(h4c, cluster = dobs[as.numeric(rownames(model.matrix(h4c))),]$towncode))
	
	h5<-lm(avg_reffoodsec~ warvict+prosociality+factor(towncode), data=dobs)
	h5_se<-coeftest(h5, vcov = vcovCluster(h5, cluster = dobs[as.numeric(rownames(model.matrix(h5))),]$towncode))
	h5c<-lm(paste("avg_reffoodsec ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h5c_se<-coeftest(h5c, vcov = vcovCluster(h5c, cluster = dobs[as.numeric(rownames(model.matrix(h5c))),]$towncode))
	
	h6<-lm(avg_refviolconf~ warvict+prosociality+factor(towncode), data=dobs)
	h6_se<-coeftest(h6, vcov = vcovCluster(h6, cluster = dobs[as.numeric(rownames(model.matrix(h6))),]$towncode))
	h6c<-lm(paste("avg_refviolconf ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs)
	h6c_se<-coeftest(h6c, vcov = vcovCluster(h6c, cluster = dobs[as.numeric(rownames(model.matrix(h6c))),]$towncode))
		
	omit<-"(towncode)|(Intercept)|(hh)|(Mus)|(gio)|(grebo)|(krahn) |(mano)|(male)|(age)|(edu)|(krahn)|(chief)"

	modelnames2<-c("% of refugee months (non coethnic refugees)","% of refugee months (non coethnic refugees)","% of refugee months (Muslim refugees)","% of refugee months (Muslim refugees)","Hosted family w/ Health Problems at arrival","Hosted family w/ Health Problems at arrival","Hosted family Food Insecure at arrival","Hosted family Food Insecure at arrival","Hosted family Fleeing Direct Violence","Hosted family Fleeing Direct Violence")		
	
	screenreg(list(h2,h2c,h3,h3c,h4, h4c, h5, h5c, h6, h6c),override.se=list(h2_se[,2], h2c_se[,2],h3_se[,2], h3c_se[,2],h4_se[,2], h4c_se[,2],h5_se[,2], h5c_se[,2],h6_se[,2], h6c_se[,2]), override.pval=list(h2_se[,4], h2c_se[,4],h3_se[,4], h3c_se[,4],h4_se[,4], h4c_se[,4],h5_se[,4], h5c_se[,4],h6_se[,4], h6c_se[,4]),digits=2, omit.coef=omit,stars=c(0.01, 0.05, 0.1),custom.model.names=modelnames2,sideways=T, bold=.1)

	
	set2<-texreg(list(h2,h2c,h3,h3c,h4, h4c, h5, h5c, h6, h6c),override.se=list(h2_se[,2], h2c_se[,2],h3_se[,2], h3c_se[,2],h4_se[,2], h4c_se[,2],h5_se[,2], h5c_se[,2],h6_se[,2], h6c_se[,2]), override.pval=list(h2_se[,4], h2c_se[,4],h3_se[,4], h3c_se[,4],h4_se[,4], h4c_se[,4],h5_se[,4], h5c_se[,4],h6_se[,4], h6c_se[,4]),digits=2, omit.coef=omit,stars=c(0.01, 0.05, 0.1),custom.model.names=modelnames2, bold=.1, scriptsize=TRUE)
	
	
	
########################################################
# APPENDIX 4.2: SOCIAL NORMS AND HOSTING
########################################################
	
	
	t4_1<-lm(avg_findself~  warvict+ age2 + age3 + age4 + age5 + chiefrelbfrwar + fatheredu + motheredu  +hhlivestockbfrwar  +hhprewar_formal  +hhprewar_business + Muslim + gio + grebo + krahn + mano +male+factor(towncode), data=dobs)
	t4_1_se<-coeftest(t4_1, vcov = vcovCluster(t4_1, cluster = dobs[as.numeric(rownames(model.matrix(t4_1))),]$towncode))
	
	t4_2<-lm(avg_bigman~ warvict +age2 + age3 + age4 + age5 + chiefrelbfrwar + fatheredu + motheredu  +hhlivestockbfrwar  +hhprewar_formal  +hhprewar_business + Muslim + gio + grebo + krahn + mano +male+factor(towncode), data=dobs)
	t4_2_se<-coeftest(t4_2, vcov = vcovCluster(t4_2, cluster = dobs[as.numeric(rownames(model.matrix(t4_2))),]$towncode))	

	t4_3<-lm(avg_commpressure~ warvict+age2 + age3 + age4 + age5 + chiefrelbfrwar + fatheredu + motheredu  +hhlivestockbfrwar  +hhprewar_formal  +hhprewar_business + Muslim + gio + grebo + krahn + mano +male+factor(towncode), data=dobs)
	t4_3_se<-coeftest(t4_3, vcov = vcovCluster(t4_3, cluster = dobs[as.numeric(rownames(model.matrix(t4_3))),]$towncode))

	modelnames1<-c("% of Families found Herself","% Families Pressured by Bigmen","% Families Pressured by Community")	
	omit<-"(towncode)|(Intercept)|(hh)|(Mus)|(gio)|(grebo)|(krahn) |(mano)|(male)|(age)|(edu)|(krahn)|(chief)"
	screenreg(list( t4_1, t4_2, t4_3),override.se=list(t4_1_se[,2], t4_2_se[,2],t4_3_se[,2]), override.pval=list(t4_1_se[,4], t4_2_se[,4],t4_3_se[,4]),digits=2, stars=c(0.01, 0.05, 0.1),sideways=T, omit.coef=omit,custom.model.names=modelnames1, bold=.1)	
	
	set1<-	texreg(list( t4_1, t4_2, t4_3),override.se=list(t4_1_se[,2], t4_2_se[,2],t4_3_se[,2]), override.pval=list(t4_1_se[,4], t4_2_se[,4],t4_3_se[,4]),digits=2, stars=c(0.01, 0.05, 0.1),sideways=F, omit.coef=omit,custom.model.names=modelnames1, bold=.1)
	
	

##############################################################
# APPENDIX 4.3: SELECTIVE MIGRATION ###############################
##############################################################

	# APPENDIX 4.3: REPLICATION OF TABLE 2 IN MAIN PAPER, SUB-SETTING TO THOSE BORN IN TOWN

	h1<-lm(nummonths_host~ warvict+factor(towncode), data=dobs[dobs$bornintown==1,])
	h1_se<-coeftest(h1, vcov = vcovCluster(h1, cluster = dobs[as.numeric(rownames(model.matrix(h1))),]$towncode))	
	h1c<-lm(paste("nummonths_host ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs[dobs$bornintown==1,])
	h1c_se<-coeftest(h1c, vcov = vcovCluster(h1c, cluster = dobs[as.numeric(rownames(model.matrix(h1c))),]$towncode))
		
	h2<-lm(host_EthnicOutgroup_dum~ warvict+factor(towncode), data=dobs[dobs$bornintown==1,])
	h2_se<-coeftest(h2, vcov = vcovCluster(h2, cluster = dobs[as.numeric(rownames(model.matrix(h2))),]$towncode))	
	h2c<-lm(paste("host_EthnicOutgroup_dum ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs[dobs$bornintown==1,])
	h2c_se<-coeftest(h2c, vcov = vcovCluster(h2c, cluster = dobs[as.numeric(rownames(model.matrix(h2c))),]$towncode))
	
	h3<-lm(host_Muslim_dum~ warvict+factor(towncode), data=dobs)
	h3_se<-coeftest(h3, vcov = vcovCluster(h3, cluster = dobs[as.numeric(rownames(model.matrix(h3))),]$towncode))	
	h3c<-lm(paste("host_Muslim_dum ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs[dobs$bornintown==1,])
	h3c_se<-coeftest(h3c, vcov = vcovCluster(h3c, cluster = dobs[as.numeric(rownames(model.matrix(h3c))),]$towncode))
	
	h4<-lm(refhealth_dum  ~ warvict+factor(towncode), data=dobs[dobs$bornintown==1,])
	h4_se<-coeftest(h4, vcov = vcovCluster(h4, cluster = dobs[as.numeric(rownames(model.matrix(h4))),]$towncode))
	h4c<-lm(paste("refhealth_dum ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs[dobs$bornintown==1,])
	h4c_se<-coeftest(h4c, vcov = vcovCluster(h4c, cluster = dobs[as.numeric(rownames(model.matrix(h4c))),]$towncode))
	
	h5<-lm(reffoodsec_dum~ warvict+factor(towncode), data=dobs[dobs$bornintown==1,])
	h5_se<-coeftest(h5, vcov = vcovCluster(h5, cluster = dobs[as.numeric(rownames(model.matrix(h5))),]$towncode))
	h5c<-lm(paste("reffoodsec_dum ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs[dobs$bornintown==1,])
	h5c_se<-coeftest(h5c, vcov = vcovCluster(h5c, cluster = dobs[as.numeric(rownames(model.matrix(h5c))),]$towncode))
	
	h6<-lm(refviolconf_dum~ warvict+factor(towncode), data=dobs[dobs$bornintown==1,])
	h6_se<-coeftest(h6, vcov = vcovCluster(h6, cluster = dobs[as.numeric(rownames(model.matrix(h6))),]$towncode))
	h6c<-lm(paste("refviolconf_dum ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs[dobs$bornintown==1,])
	h6c_se<-coeftest(h6c, vcov = vcovCluster(h6c, cluster = dobs[as.numeric(rownames(model.matrix(h6c))),]$towncode))
	
	
	omit<-"(towncode)|(Intercept)|(hh)|(Mus)|(gio)|(grebo)|(krahn) |(mano)|(male)|(age)|(edu)|(krahn)|(chief)"
	modelnames1<-c("# Refugee Months Host","# Refugee Months Host","# Refugee Months Host (Ethnic Outgroup)","# Refugee Months Host (Ethnic Outgroup)"," # Refugee Months Host (Religious Outgroup)","# Refugee Months Host (Religious Outgroup)")
	modelnames2<-c("# Refugee Families w/ Health Problems at arrival","# Refugee Families w/ Health Problems at arrival","# Refugee Families Food Insecure at arrival","# Refugee Families Food Insecure at arrival","# Refugee Families Fleeing Direct Violence","# Refugee Families Fleeing Direct Violence")
	
	screenreg(list(h1, h1c, h2, h2c, h3, h3c),override.se=list(h1_se[,2], h1c_se[,2],h2_se[,2], h2c_se[,2],h3_se[,2], h3c_se[,2]), override.pval=list(h1_se[,4], h1c_se[,4],h2_se[,4], h2c_se[,4],h3_se[,4], h3c_se[,4]),digits=2, stars=c(0.01, 0.05, 0.1),sideways=T, omit.coef=omit,custom.model.names=modelnames1, bold=.1,scriptsize=TRUE)

	screenreg(list(h4, h4c, h5, h5c, h6, h6c),override.se=list(h4_se[,2], h4c_se[,2],h5_se[,2], h5c_se[,2],h6_se[,2], h6c_se[,2]), override.pval=list(h4_se[,4], h4c_se[,4],h5_se[,4], h5c_se[,4],h6_se[,4], h6c_se[,4]),digits=2, omit.coef=omit,stars=c(0.01, 0.05, 0.1),custom.model.names=modelnames2,sideways=T, bold=.1,scriptsize=TRUE)
	
	
	set1<-texreg(list(h1, h1c, h2, h2c, h3, h3c),override.se=list(h1_se[,2], h1c_se[,2],h2_se[,2], h2c_se[,2],h3_se[,2], h3c_se[,2]), override.pval=list(h1_se[,4], h1c_se[,4],h2_se[,4], h2c_se[,4],h3_se[,4], h3c_se[,4]),digits=2, stars=c(0.01, 0.05, 0.1), omit.coef=omit,custom.model.names=modelnames1, bold=.1,scriptsize=TRUE)

	set2<-texreg(list(h4, h4c, h5, h5c, h6, h6c),override.se=list(h4_se[,2], h4c_se[,2],h5_se[,2], h5c_se[,2],h6_se[,2], h6c_se[,2]), override.pval=list(h4_se[,4], h4c_se[,4],h5_se[,4], h5c_se[,4],h6_se[,4], h6c_se[,4]),digits=2, omit.coef=omit,stars=c(0.01, 0.05, 0.1),custom.model.names=modelnames2, bold=.1,scriptsize=TRUE)

	

# APPENDIX 4.3: REPLICATION OF TABLE 3 IN MAIN PAPER, SUB-SETTING TO THOSE BORN IN TOWN


	h2<-lm(per_nummonths_host_noncoeth~ warvict+factor(towncode), data=dobs[dobs$bornintown==1,])
	h2_se<-coeftest(h2, vcov = vcovCluster(h2, cluster = dobs[as.numeric(rownames(model.matrix(h2))),]$towncode))
	h2c<-lm(paste("per_nummonths_host_noncoeth ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs[dobs$bornintown==1,])
	h2c_se<-coeftest(h2c, vcov = vcovCluster(h2c, cluster = dobs[as.numeric(rownames(model.matrix(h2c))),]$towncode))
	
	h3<-lm(per_nummonths_host_Muslim~ warvict+factor(towncode), data=dobs[dobs$bornintown==1,])
	h3_se<-coeftest(h3, vcov = vcovCluster(h3, cluster = dobs[as.numeric(rownames(model.matrix(h3))),]$towncode))
	h3c<-lm(paste("per_nummonths_host_Muslim ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs[dobs$bornintown==1,])
	h3c_se<-coeftest(h3c, vcov = vcovCluster(h3c, cluster = dobs[as.numeric(rownames(model.matrix(h3c))),]$towncode))
	
	h4<-lm(avg_refhealth~ warvict+factor(towncode), data=dobs[dobs$bornintown==1,])
	h4_se<-coeftest(h4, vcov = vcovCluster(h4, cluster = dobs[as.numeric(rownames(model.matrix(h4))),]$towncode))
	h4c<-lm(paste("avg_refhealth ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs[dobs$bornintown==1,])
	h4c_se<-coeftest(h4c, vcov = vcovCluster(h4c, cluster = dobs[as.numeric(rownames(model.matrix(h4c))),]$towncode))
	
	h5<-lm(avg_reffoodsec~ warvict+factor(towncode), data=dobs[dobs$bornintown==1,])
	h5_se<-coeftest(h5, vcov = vcovCluster(h5, cluster = dobs[as.numeric(rownames(model.matrix(h5))),]$towncode))
	h5c<-lm(paste("avg_reffoodsec ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs[dobs$bornintown==1,])
	h5c_se<-coeftest(h5c, vcov = vcovCluster(h5c, cluster = dobs[as.numeric(rownames(model.matrix(h5c))),]$towncode))
	
	h6<-lm(avg_refviolconf~ warvict+factor(towncode), data=dobs[dobs$bornintown==1,])
	h6_se<-coeftest(h6, vcov = vcovCluster(h6, cluster = dobs[as.numeric(rownames(model.matrix(h6))),]$towncode))
	h6c<-lm(paste("avg_refviolconf ~ warvict+", paste(ctrls, collapse= "+"), paste("+factor(towncode)")), data=dobs[dobs$bornintown==1,])
	h6c_se<-coeftest(h6c, vcov = vcovCluster(h6c, cluster = dobs[as.numeric(rownames(model.matrix(h6c))),]$towncode))
		
	omit<-"(towncode)|(Intercept)|(hh)|(Mus)|(gio)|(grebo)|(krahn) |(mano)|(male)|(age)|(edu)|(krahn)|(chief)"

	modelnames2<-c("% of refugee months (non coethnic refugees)","% of refugee months (non coethnic refugees)","% of refugee months (Muslim refugees)","% of refugee months (Muslim refugees)","% Refugee Families w/ Health Problems at arrival","% Refugee Families w/ Health Problems at arrival","% Refugee Families Food Insecure at arrival","% Refugee Families Food Insecure at arrival","% Refugee Families Fleeing Direct Violence","% Refugee Families Fleeing Direct Violence")		
	
	screenreg(list(h2,h2c,h3,h3c,h4, h4c, h5, h5c, h6, h6c),override.se=list(h2_se[,2], h2c_se[,2],h3_se[,2], h3c_se[,2],h4_se[,2], h4c_se[,2],h5_se[,2], h5c_se[,2],h6_se[,2], h6c_se[,2]), override.pval=list(h2_se[,4], h2c_se[,4],h3_se[,4], h3c_se[,4],h4_se[,4], h4c_se[,4],h5_se[,4], h5c_se[,4],h6_se[,4], h6c_se[,4]),digits=2, omit.coef=omit,stars=c(0.01, 0.05, 0.1),custom.model.names=modelnames2,sideways=T, bold=.1)

	
	set2<-texreg(list(h2,h2c,h3,h3c,h4, h4c, h5, h5c, h6, h6c),override.se=list(h2_se[,2], h2c_se[,2],h3_se[,2], h3c_se[,2],h4_se[,2], h4c_se[,2],h5_se[,2], h5c_se[,2],h6_se[,2], h6c_se[,2]), override.pval=list(h2_se[,4], h2c_se[,4],h3_se[,4], h3c_se[,4],h4_se[,4], h4c_se[,4],h5_se[,4], h5c_se[,4],h6_se[,4], h6c_se[,4]),digits=2, omit.coef=omit,stars=c(0.01, 0.05, 0.1),custom.model.names=modelnames2, bold=.1, scriptsize=TRUE)
	
	
##########################################################
########### APPENDIX 4.4 NON-ASSOCIATION OF VIOLENCE AND RECIPROCITY #########
##########################################################

	t44_1<-lm(lrefugee~ warvict+ age2 + age3 + age4 + age5 + chiefrelbfrwar + fatheredu + motheredu  +hhlivestockbfrwar  +hhprewar_formal  +hhprewar_business + Muslim + gio + grebo + krahn + mano +male+factor(towncode), data=dobs)
	t44_1_se<-coeftest(t44_1, vcov = vcovCluster(t44_1, cluster = dobs[as.numeric(rownames(model.matrix(t44_1))),]$towncode))
	
	t44_2<-lm(lrefugee_coethnichost~ warvict+ age2 + age3 + age4 + age5 + chiefrelbfrwar + fatheredu + motheredu  +hhlivestockbfrwar  +hhprewar_formal  +hhprewar_business + Muslim + gio + grebo + krahn + mano +male+factor(towncode), data=dobs)
	t44_2_se<-coeftest(t44_2, vcov = vcovCluster(t44_2, cluster = dobs[as.numeric(rownames(model.matrix(t44_2))),]$towncode))
	
	t44_1_se[1:5,]; t44_2_se[1:5,];

	
	omit<-"(towncode)|(Intercept)|(hh)|(Mus)|(gio)|(grebo)|(krahn) |(mano)|(male)|(age)|(edu)|(krahn)|(chief)"
	modelnames1<-c("Previously a refugee?","Previously a refugee and stayed with co-ethnic family")
	
	screenreg(list(t44_1,t44_2),override.se=list(t44_1_se[,2], t44_2_se[,2]), override.pval=list(t44_1_se[,4], t44_2_se[,4]),digits=2, stars=c(0.01, 0.05, 0.1),sideways=T, omit.coef=omit,custom.model.names=modelnames1, bold=.1,scriptsize=TRUE)

	set1<-texreg(list(t44_1,t44_2),override.se=list(t44_1_se[,2], t44_2_se[,2]), override.pval=list(t44_1_se[,4], t44_2_se[,4]),digits=2, stars=c(0.01, 0.05, 0.1),sideways=T, omit.coef=omit,custom.model.names=modelnames1, bold=.1,scriptsize=TRUE)
	
	
	

########################################################
# MISCELLANEOUS TESTS
########################################################

	# CORRELATION OF REFUGEE EXPERIENCE AND WAR VICTIMIZATION
	
	violence_refugee<-lm(lrefugee~ warvict+ age2 + age3 + age4 + age5 + chiefrelbfrwar + fatheredu + motheredu  +hhlivestockbfrwar  +hhprewar_formal  +hhprewar_business + Muslim + gio + grebo + krahn + mano +male+factor(towncode),data=dobs)
		violence_refugee_se<-coeftest(violence_refugee, vcov =vcovCluster(violence_refugee, cluster = d[as.numeric(rownames(model.matrix(violence_refugee))),]$towncode))


		


		
		
		
		
		
		
		
		
		
		